<template>
    <div class="app">
        <div class="like">
            <div class="choice" >
                <span v-for="(item,index) in likeArr" :key="index" @click="handleClick(item,index)" :class="{active: currentIndex == index }">{{item}}</span>
            </div>
            <div class="type" >
                <span v-for="(item,index) in typeArr" :key="index">{{item}}</span>
            </div>
        </div>
        <!-- 列表 -->
        <div class="good">
            <div class="xinxi"  v-for="(item,index) in searchlist" :key="index" @click="toDetail(item)">
                <div class="imgbox">
                <img :src="item.picUrl" alt="" />
                </div>
                <div class="dian">
                <div class="title">{{item.name}}</div>
                <div class="psh">
                    <span>￥{{item.wmPoiScore/10}}</span>
                    <span>{{item.monthSalesTip}}</span>
                </div>
                <div class="song">
                    <div class="qisong">
                    <span>{{item.minPriceTip}}</span>
                    <span>{{item.shippingFeeTip}}</span>
                    </div>
                    <div class="min">
                    <span>{{item.deliveryTimeTip}}</span>
                    <span>{{item.distance}}</span>
                    </div>
                </div>
                <div class="pjia">
                    <span></span>
                </div>
                <div class="jian">
                    <span v-for="(item,index) in item.discounts2" :key="index">{{item.info}}</span>
                </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { mapState,mapMutations} from 'vuex'
export default {
data(){
    return {
        currentIndex:0,
        likeArr:['综合排序','距离最近','销量最高','筛选'],
        typeArr:['年货节热卖','津贴联盟'],
        list:[],
    }
    },
    computed:{
        ...mapState(['searchArr']),
        ...mapState(['searchlist']),
    },
    mounted(){


    },
    methods:{
    handleClick(item,index){
        this.currentIndex = index;
        if(index == 1){
            this.searchlist.sort((a,b)=>{
            // console.log(a.distance);
            return a.wmPoiScore - b.wmPoiScore;
            })
        }else if(index == 2){
            this.searchlist.sort((a,b)=>{
            // console.log(a.monthSalesTip);
                return b.wmPoiScore - a.wmPoiScore;
            })
        }
    },
    toDetail(item){
            this.$router.push('/detail/'+item.mtWmPoiId);
        }
    },
}
</script>

<style lang="scss" scoped>
.like{

    margin:10px 0 5px;
    flex-wrap: wrap;
}
.like .choice{
    display: flex;
    justify-content: space-around;
}
.like .choice span.active{
    color:orangered;
    font-weight: bolder;
}
.like .type{
    width: 94%;
    margin: auto;
    margin-top: 10px;
    display: flex;
    // justify-content: space-around;
}
.like .type span{
    background-color: #fff;
    box-shadow: 0 8px 12px #ebedf0;
    padding: 5px 15px;
    font-size: 12px;
    border-radius: 5px;
    margin-bottom: 5px;
}
.like .type span:nth-child(2){
    margin-left: 10px;
}

.list .shop{
    margin: 10px;
    display: flex;
}
.good{
    padding-top: 5px;
    background-color: #f5f5f5;
    height: 100%;
}
/* 店铺信息 */
.xinxi {
    box-sizing: border-box;
    display: flex;
    background-color: #fff;
    border-radius: 10px ;
    margin: 10px;
    box-shadow: 0 8px 12px #ebedf0;
}

.xinxi .imgbox {
    width: 62.3px;
    height: 76.8px;
    margin-top: 30px;
    margin-left: 10px;
    margin-right: 10px;
}

.xinxi .imgbox img {
    width: 100%;
    height: 100%;
}
.xinxi .imgbox img:nth-child(2) {
    width: 80px;
}


/* 店铺详细信息 */
.xinxi .dian {
    display: flex;
    flex-direction: column;
}


/* 店铺名称 */
.xinxi .dian .title {
    font-weight: bolder;
    margin-top: 10px;
    margin-bottom: 15px;
}

/* 月售 */
.xinxi .dian .psh {
    font-size: 12px;
    color: #999;
    margin-bottom: 5px;
}

.xinxi .dian .psh span {
    display: inline-block;
    margin-right: 5px;
}

.xinxi .dian .psh span:nth-child(1) {
    color: orangered;
}

/* 配送 */
.xinxi .dian .song {
    color: #999;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.xinxi .dian .song .qisong {
    flex: 1;
    margin-right: 10px;
}

.xinxi .dian .song .qisong span:nth-child(3) {
    font-size: 6px;
    color: #999;
    text-decoration: line-through;
}

.xinxi .dian .song span {
    display: inline-block;
    margin-right: 2px;
}

/* 评价 */
.xinxi .dian .pjia {
    font-size: 10px;
    color: orange;
    margin-bottom: 5px;
}

.xinxi .dian .pjia span {
    background-color: rgb(226, 210, 181);
    margin-right: 4px;
    border-radius: 4px;
}

/* 满减 */

.xinxi .dian .jian {
    // display: flex;
    font-size: 10px;
}
.xinxi .dian .jian span {
    font-size: 8px;
    margin: 2px 0;
    color: orangered;
    border: 1px solid orangered;
    display: inline-block;
    margin-right: 5px;
    margin-bottom: 10px;
    border-radius: 4px;
}

/* 排序点击后样式的变化 */
.bol {
    font-weight: bold;
}
</style>